#pragma once

#include <sys_reg.h>

typedef enum {
	USART0_Q = 0x40013800,
	USART1_Q = 0x40004400,
	USART2_Q = 0x40004800,
	UART3_Q = 0x40004C00,
	UART4_Q = 0x40005000,
} usart_qe;

typedef enum {
	USART_STAT_R = 0x0,
	USART_DATA_R = 0x4,
	USART_BAUD_R = 0x8,
	USART_CTL0_R = 0xC,
	USART_CTL1_R = 0x10,
	USART_CTL2_R = 0x14,
	USART_GP_R = 0x18,
} usart_re;

static inline u32_s usart_get_reg_q(usart_qe usart_q, usart_re usart_r) {
	return usart_q + usart_r;
}

static inline void usart_wreg(usart_qe usart_q, usart_re usart_r, u32_s value) {
	u32_s reg_q = usart_get_reg_q(usart_q, usart_r);
	wreg(reg_q, value);
}

static inline u32_s usart_rreg(usart_qe usart_q, usart_re usart_r) {
	u32_s reg_q = usart_get_reg_q(usart_q, usart_r);
	return rreg(reg_q);
}
